package de.haw.adt.implementation;

import static de.haw.adt.implementation.Values.SEC_IN_H;
import de.haw.adt.interfaces.ITimeDiff;

class TimeDiff extends AbstractPhysicalScalar implements ITimeDiff {

	private final double seconds;

	private TimeDiff(double seconds) {
		this.seconds = seconds;
	}
	
	@Override
	double getValue() {
		return seconds;
	}

	public int compareTo(ITimeDiff time) {
		return Double.compare(this.getS(), time.getS());
	}

	@Override
	public boolean equals(Object o) {
		if (o == this)
			return true;
		if (!(o instanceof TimeDiff))
			return false;
		return this.compareTo((TimeDiff) o) == 0;
	}

	public double getS() {
		return seconds;
	}

	public double getH() {
		return seconds / SEC_IN_H;
	}

	public ITimeDiff div(double factor) {
		return valueOf(this.seconds / factor);
	}
	
	public static ITimeDiff valueOf(double seconds) {
		return new TimeDiff(seconds);
	}
}
